<template>
  <VabDrawer v-model="isShowDialog" :close-on-click-modal="true" show-fullscreen title="用户信息" width="30%">
    <CommonForm ref="commonFormRef" v-model="form" :layout-config="layoutConfig" :option="option" @on-cancel="handleClose">
      <template #orgSlot>
        <SelectVxeTreeOne
          v-model="form.orgid"
          :disabled="true"
          :placeholder="'请选择'"
          :query-form="{ pageSize: -1, sorts: 'cts@asc' }"
          :searchable="false"
          :url="'system/org/query'"
        />
      </template>
    </CommonForm>
    <template #footer>
      <el-button @click="handleClose">取 消</el-button>
    </template>
  </VabDrawer>
</template>

<script>
import CommonForm from "@/plugins/form/CommonForm.vue";
import VabDrawer from "@/plugins/VabDialog/drawerModule.vue";
import SelectVxeTreeOne from "@/plugins/tree/SelectVxeTreeOne.vue";
import { TableColumnOrFormTypeEnum } from "@/plugins/commonType.enum";

export default defineComponent({
  name: "UserInfo",
  components: {
    CommonForm,
    VabDrawer,
    SelectVxeTreeOne
  },
  props: {},
  emits: { "on-success": null },

  setup(props, { expose }) {
    /**
     * form组件布局
     */
    const layoutConfig = reactive({
      column: 1
    });

    const isShowDialog = ref(false);
    const form = ref({});

    const option = {
      column: [
        {
          label: "登录名",
          prop: "userName",
          type: TableColumnOrFormTypeEnum.INPUT
        },
        {
          label: "用户昵称",
          prop: "nickName",
          type: TableColumnOrFormTypeEnum.INPUT
        },
        {
          label: "用户类型",
          prop: "userType",
          type: TableColumnOrFormTypeEnum.SELECT,
          dictCode: "UserType"
        },
        {
          label: "所属机构",
          type: TableColumnOrFormTypeEnum.SLOT,
          slotName: "orgSlot",
          prop: "orgid",
          placeholder: "请选择所属机构"
        },
        {
          label: "性别",
          prop: "sex",
          type: TableColumnOrFormTypeEnum.SELECT,
          dictCode: "sys_user_sex"
        },
        {
          label: "邮箱",
          prop: "email",
          type: TableColumnOrFormTypeEnum.INPUT
        },
        {
          label: "手机号码",
          prop: "phonenumber",
          type: TableColumnOrFormTypeEnum.INPUT
        },
        {
          label: "地址",
          prop: "address",
          type: TableColumnOrFormTypeEnum.INPUT
        },
        {
          label: "用户描述",
          prop: "memo",
          type: TableColumnOrFormTypeEnum.TEXTAREA,
          placeholder: "请输入用户描述"
        }
      ],
      formConfig: {
        // title: '基本信息',
        disabled: true,
        isInModal: true
      },
      btnsConfig: {
        save: {
          isShow: false
        },
        back: {
          isShow: false
        }
      },
      rules: {}
    };
    const showDialog = row => {
      if (row) {
        form.value = row;
      } else {
        form.value = {};
      }
      isShowDialog.value = true;
    };

    const handleClose = () => {
      isShowDialog.value = false;
    };

    expose({ showDialog });
    return {
      isShowDialog,
      form,
      option,
      layoutConfig,
      handleClose
    };
  }
});
</script>

<style lang="scss" scoped></style>
